//点击顾客订单
function clickOrders(status){
	//这是有问题商品
	window.location.href="../orders/getGoodsOfAfterSale.do?currentPage=1&&status="+status
}

//makeOrderTbody顾客订单
function makeOrderTr(indent){	
	var imgs=JSON.stringify(indent.imgs);
	var tr=$('<tr class="gradeA even"></tr>');
	//方式
	var method="";
	if(indent.askMethod==0){
		method="退货";
	}else if(indent.askMethod==1){
		method="换货";
	}else if(indent.askMethod==2){
		method="维修";
	}
	tr.append("<td>" +indent.goodsId+"</td>" +
			  "<td><img src='http://oeilufnx2.bkt.clouddn.com/"+indent.sampleImg+"?imageView2/1/w/100/h/100'></td>" +
			  "<td>" +indent.sampleDescribe+"</td>" +
			  "<td>" +indent.nickName+"</td>" +
			  "<td>" +indent.phone+"</td>" +
			  "<td>" +indent.orderId+"</td>" +   
			  "<td>"+indent.problem+"</td>" +
			  "<td data-toggle='modal' data-target='#myModal'><img src='http://oeilufnx2.bkt.clouddn.com/"+indent.imgs[0]+"?imageView2/1/w/100/h/100'  onclick='showImgs("+imgs+")'></td>" +
			  "<td>" +indent.finishTime+"</td>" +
			  "<td>" +indent.disposeTime+"</td>" +
			  "<td>" +method+"</td>" +
			  '<td><button class="btn btn-info" type="button"  data-toggle="modal" data-target="#myModal2" onclick="goToGoodsOfHasProblem('+indent.goodsId+')">处理</button></td>'
			 );
	return tr;
}
//把商品id带到处理问题的界面
function goToGoodsOfHasProblemAgree(goodsId){
	console.log("商品id=",goodsId);
	$("#handleProblemGoods>input").val(goodsId);
	//根据商品id获取该商品的处理方式, 并进行处理
	
}

//图片的点击事件
function showImgs(imgs){
	imgs=imgs.replace("[","");
	imgs=imgs.replace("]","");
	imgs=imgs.split(",");
	imgs=JSON.stringify(imgs);
	imgs=imgs.replace(/\s/g,"");
	imgs=JSON.parse(imgs);
	$("#goodPricture").empty();
	for(var i=0;i<imgs.length;i++){
		$("#goodPricture").append("<h3>问题图片"+(i+1)+"</h3>");
		$("#goodPricture").append('<img alt="" src="http://oeilufnx2.bkt.clouddn.com/'+imgs[i]+'?imageView2/1/w/800/h/800">');
	}
	
}
//分页
function makeFenYe(method,page,status){
	var rootDiv=$('<div class="row-fluid">');
	var secondDiv=$('<div class="span6">');
	var threeDiv=$('<div class="dataTables_paginate paging_bootstrap pagination">')
	var ul=$('<ul>');
	var lastLi=$('<li class="prev">');
	var nextLi=$('<li class="next">');
	var aLast=$('<a class="page-link">← 上一页</a>');
	var aNext=$('<a class="page-link">下一页 → </a>');	
	if(page.currentPage>1){
		aLast.attr({onclick:method+"("+(page.currentPage-1)+","+status+")"});
	}
	if(page.currentPage<page.totalPage){
		aNext.attr({onclick:method+"("+(page.currentPage+1)+","+status+")"});
	}
	lastLi.append(aLast);
	nextLi.append(aNext);
	ul.append(lastLi);
	if(4>page.totalPage>0){
		for(var i=1;i<page.totalPage+1;i++){
			if(i==page.currentPage){
				ul.append('<li class="page-item active"><a onclick="'+method+'('+i+","+status+')">'+i+'</a></li>');
			}else{
				ul.append('<li class="page-item"><a onclick="'+method+'('+i+","+status+')">'+i+'</a></li>');
			}
			
		}   
	}
	if(page.totalPage>3){
		if(page.currentPage==1){
			ul.append('<li class="page-item active"><a onclick="'+method+'('+page.currentPage+","+status+')">'+page.currentPage+'</a></li>');
			ul.append('<li class="page-item"><a onclick="'+method+'('+(page.currentPage+1)+","+status+')">'+(page.currentPage+1)+'</a></li>');
			ul.append('<li class="page-item"><a onclick="'+method+'('+(page.currentPage+2)+","+status+')">'+(page.currentPage+2)+'</a></li>');

		}else if(page.currentPage==2){
			ul.append('<li class="page-item"><a onclick="'+method+'('+(page.currentPage-1)+","+status+')">'+(page.currentPage-1)+'</a></li>');
			ul.append('<li class="page-item active"><a onclick="'+method+'('+page.currentPage+","+status+')">'+page.currentPage+'</a></li>');
			ul.append('<li class="page-item"><a onclick="'+method+'('+(page.currentPage+1)+","+status+')">'+(page.currentPage+1)+'</a></li>');			
		}else{
			if(page.currentPage==page.totalPage){
				ul.append('<li class="page-item"><a class="page-link">...</a></li>');
				ul.append('<li class="page-item"><a onclick="'+method+'('+(page.currentPage-1)+","+status+')">'+(page.currentPage-1)+'</a></li>');
				ul.append('<li class="page-item active"><a onclick="'+method+'('+page.currentPage+","+status+')">'+page.currentPage+'</a></li>');				
				ul.append('<li class="page-item"><a class="page-link">...</a></li>');
			}else{
				ul.append('<li class="page-item"><a class="page-link">...</a></li>');
				ul.append('<li class="page-item"><a onclick="'+method+'('+(page.currentPage-1)+","+status+')">'+(page.currentPage-1)+'</a></li>');
				ul.append('<li class="page-item active"><a onclick="'+method+'('+page.currentPage+","+status+')">'+page.currentPage+'</a></li>');
				ul.append('<li class="page-item"><a onclick="'+method+'('+(page.currentPage+1)+","+status+')">'+(page.currentPage+1)+'</a></li>');
				ul.append('<li class="page-item"><a class="page-link">...</a></li>');	
			}
		}

	}
	ul.append(nextLi);
	ul.append('<li class="page-item"><a>总共'+page.totalPage+'页</a></li>');
	threeDiv.append(ul);
	secondDiv.append(threeDiv);
	rootDiv.append(secondDiv);
	return rootDiv;
}



